<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>localStorage</title>
	</head>
	<body>
		<button type="button" onclick="saveData()">点我保存一个数据</button>
		<button type="button" onclick="readData()">点我读取一个数据</button>
		<button type="button" onclick="deleteData()">点我删除一个数据</button>
		<button type="button" onclick="deleteAllData()">点我清空所有数据</button>
		<script type="text/javascript">
			function saveData(){
				let p = {name:"张三",age:18}
				window.localStorage.setItem('msg',"hello")
				window.localStorage.setItem('person',JSON.stringify(p))
			}
			function readData(){
				
				window.localStorage.getItem('msg')
				window.localStorage.getItem('person',JSON.stringify(p))
			}
			function deleteData(){
				window.localStorage.removeItem('msg')
				window.localStorage.removeItem('person')
			}
			function deleteAllData(){
				window.localStorage.clear()
			}
		</script>
	</body>
</html>
